** numbers_2002-2016_duplicatesdropped.dta 파일 생성
use numbers, clear
merge 1:1 appnum using basicinfo, keepusing(registerdate regi) keep(3) nogenerate
gen regi_year = substr(registerdate, 1, 4)
gen app_year = floor(appnum/10000000)-100000
gen open_year = substr(opennum, 4, 4)
destring regi_year open_year, replace
drop if regi_year<2002 | regi_year>2016
keep appnum registernum opennum publicnum app_year open_year regi_year
order appnum registernum opennum publicnum app_year open_year regi_year
drop if registernum=="10-1241806-0000" & appnum==1020100066316 
drop if registernum=="10-1424071-0000" & appnum==1020120019425 
save numbers_2002-2016_duplicatesdropped, replace


** numbers_2002-2016_opennumdropped.dta 파일 생성
use numbers, clear
merge 1:1 appnum using basicinfo, keepusing(registerdate regi) keep(3) nogenerate
gen regi_year = substr(registerdate, 1, 4)
gen app_year = floor(appnum/10000000)-100000
gen open_year = substr(opennum, 4, 4)
destring regi_year open_year, replace
drop if regi_year<2002 | regi_year>2016
keep appnum registernum opennum publicnum app_year open_year regi_year
order appnum registernum opennum publicnum app_year open_year regi_year
drop if opennum==" " | opennum=="10-0000-0000000"
replace opennum="10-1993-0022550" if opennum=="10-1993-0022549" & appnum==1019930006545
drop if opennum=="10-2000-0062651"
save numbers_opennumdropped, replace
